#!/bin/sh

set -e

if [ ! -f "$1" ]; then
        echo "usage: $(basename "$0") FILE"
        exit 1
fi

. "$(readlink -f "$1")"

DEV="gt-udp-$(basename "$1")"

exec glorytun \
	bind to addr ${HOST:-::} port ${PORT:-5000} from addr $BIND port $BIND_PORT \
	keyfile "$1".key \
	${DEV:+dev "$DEV"} \
	${OPTIONS:+$OPTIONS}
